from base.base import *
from page.page_index import *
from tools.tool_logger import *

class IndexPage(Base):

    def __init__(self, driver):
        logger.info('IndexPage浏览器实例化开始')
        super().__init__(driver)


    def page_input_username(self, value):
        logger.info('IndexPage输入用户名开始')
        self.base_send_keys(IndexPageElements.input_username, value)


    def page_input_password(self, value):
        logger.info('IndexPage输入密码开始')
        self.base_send_keys(IndexPageElements.input_password, value)


    def page_click_login_btn(self):
        logger.info('IndexPage点击登录按钮开始')
        self.base_click(IndexPageElements.login_btn)

    def page_get_login_fail_text(self):
        logger.info('IndexPage获取登录失败信息开始')
        return self.base_get_text(IndexPageElements.login_fail_text)

    def page_get_screenshot_as_file(self, file_name):
        logger.info('IndexPage获取屏幕截图开始')
        return self.base_get_screenshot_as_file(file_name)


    def go_to_homepage(self, username, password):
        logger.info('IndexPage登录后跳转首页开始')
        self.page_input_username(username)
        self.page_input_password(password)
        self.page_click_login_btn()
